package com.example.demo.execute;

import com.example.demo.enums.SimpleEnum;
import com.example.demo.enums.TypeEnum;

public class execute {
    public static void main(String[] args) {
        forEnum();
        uesEnumInJava();
    }
    private static void forEnum(){
        for (SimpleEnum simpleEnum : SimpleEnum.values()) {
            System.out.println(simpleEnum +" ordinal "+ simpleEnum.ordinal());
        }
        System.out.println("---------------------");
        for (TypeEnum typeEnum : TypeEnum.values()) {
            System.out.println("typeEnum = " + typeEnum +
                    " typeEnum.name = " + typeEnum.name() +
                    " typeEnumName = " + typeEnum.getTypeName() +
                    " typeEnumOrdinal = " + typeEnum.ordinal() );
        }
    }
    private static void uesEnumInJava(){
        String typeName = "f5";
        TypeEnum typeEnum = TypeEnum.formTypeName(typeName);
        if (TypeEnum.BALANCE.equals(typeEnum)){
            System.out.println("根据字符串获得的枚举类型实例跟枚举常量一致");
        }else {
            System.out.println("大师兄代码错误");
        }
    }


}
